public class BinarySearchTree {
    static class TreeNode {
        public int val;
        public TreeNode left ;
        public TreeNode right;
        public TreeNode(int val) {
            this.val = val;
        }
    }
    public TreeNode root = null;

    public TreeNode search(int val){
//查找val是不是在当前的搜索书当中
        TreeNode cur = root;
        while(cur!= null){
            if(cur.val < val){
                cur = cur.right;
            }else if(cur.val > val){
                cur = cur.left;
            }else{
                return  cur;
            }
        }
        return null;
    }

}
